﻿using UnityEngine;
using System.Collections;

public class Block : MonoBehaviour {
	//是否可触摸
	public bool canTouch = true;

	//预设类型
	public int blockType = 0;

	private float offsetX = -2.3f;
	private float offsetY = -3.8f;
	// Use this for initialization

	private GameController gameController;

	public int rowIndex;
	public int columnIndex;

	void Awake(){
		gameController = GameObject.FindObjectOfType<GameController> ();
	}
	void Start () {
	
	}
	
	// Update is called once per frame
	void OnMouseDown () {
		Debug.Log ("OnMouseDown");

		//下移
		gameController.Select (this);
		/*
		int col = Random.Range (0, 4);
		int row = Random.Range (0, 4);
		SetPosition (row, col);
		*/
	}

	public void SetPosition(int row, int col){
		this.rowIndex = row;
		this.columnIndex = col;

		Vector3 pos = new Vector3 (offsetX+col*1.5f, offsetY + row*2.55f,0);
		transform.position = pos;
	}

	//色块往下移动一行
	public void MoveDown(){
		SetPosition (this.rowIndex-1, this.columnIndex);
	}
}
